package com.bnz.mapper.controller;

import java.util.Arrays;
import java.util.Map;

import com.bnz.untis.PageUtils;
import com.bnz.untis.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.bnz.mapper.entity.ContentEntity;
import com.bnz.mapper.service.ContentService;




/**
 * 广告
 *
 * @author WF
 * @email 1966628784@qq.com
 * @date 2022-09-12 20:13:35
 */
@RestController
@RequestMapping("mapper/content")
public class ContentController {
    @Autowired
    private ContentService contentService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = contentService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
		ContentEntity content = contentService.getById(id);

        return R.ok().put("content", content);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody ContentEntity content){
		contentService.save(content);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public R update(@RequestBody ContentEntity content){
		contentService.updateById(content);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody String[] ids){
		contentService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
